//
//  JMInductionCell.m
//  OpenSesame
//
//  Created by zhangjiaming on 15/12/29.
//  Copyright © 2015年 OpenSesame. All rights reserved.
//

#import "JMInductionCell.h"

@implementation JMInductionCell

- (void)awakeFromNib {
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        CGFloat ratio = 710.0/376.0; // 图片宽高比
        // 设置背景
        UIImageView *imageView = [[UIImageView alloc] init];
        self.backImageVIew = imageView;
        CGFloat imageViewW = JMPhoneWidth - 20;
        CGFloat imageViewH = imageViewW/ratio;
        imageView.frame = CGRectMake(10, 0, imageViewW, imageViewH);
        [self.contentView addSubview:imageView];
        
        // 添加imageView里面的label
        UILabel *label = [[UILabel alloc] init];
        self.label = label;
        [imageView addSubview:label];
        label.textColor = [UIColor whiteColor];
        label.textAlignment = NSTextAlignmentCenter;
        label.font = [UIFont boldSystemFontOfSize:28];
        CGFloat labelW = 89;
        CGFloat labelH = 75;
        label.frame = CGRectMake((imageView.width - labelW) * 0.5 , (imageView.height - labelH) * 0.5, labelW, labelH);
        self.height = imageViewH + 10;
    }
    return self;
}

+ (JMInductionCell *)cellWithTableView:(UITableView *)tableView {
    static NSString *ID = @"induction";
    JMInductionCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[JMInductionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
@end
